import request from '@/utils/request'

/**
 * 获取笔记列表
 */
export function getNotes(params) {
  return request({
    url: '/notes',
    method: 'get',
    params
  })
}

/**
 * 获取笔记详情
 */
export function getNote(id) {
  return request({
    url: `/notes/${id}`,
    method: 'get'
  })
}

/**
 * 创建笔记
 */
export function createNote(data) {
  return request({
    url: '/notes',
    method: 'post',
    data
  })
}

/**
 * 更新笔记
 */
export function updateNote(id, data) {
  return request({
    url: `/notes/${id}`,
    method: 'put',
    data
  })
}

/**
 * 删除笔记
 */
export function deleteNote(id) {
  return request({
    url: `/notes/${id}`,
    method: 'delete'
  })
}

/**
 * 搜索笔记
 */
export function searchNotes(keyword, limit = 50) {
  return request({
    url: '/notes/search',
    method: 'get',
    params: { keyword, limit }
  })
}

/**
 * 获取推荐笔记
 */
export function getRecommendedNotes(id, limit = 5) {
  return request({
    url: `/notes/${id}/recommendations`,
    method: 'get',
    params: { limit }
  })
}

